#include "Renderer.h"
#include "Platform/OpenGL/OpenGLShader.h"
#include "Renderer2D.h"
#include "Debug/Instrumentor.h"

namespace Hazel {
    Renderer::SceneDatta* Renderer::m_SceneData = new Renderer::SceneDatta;
    void Renderer::Init() {
        HZ_PROFILE_FUNCTION();
        RenderCommand::Init();
        Renderer2D::Init();
    }
    void Renderer::BeginScene(OrthographicCamera(& camera)){
        m_SceneData->ViewProjectionMatrix = camera.GetViewProjectionMatrix();
    }

    void Renderer::EndScene(){


    }
    void Renderer::Shutdown()
    {
        Renderer2D::Shutdown();
    }

    void Renderer::Submit(const Ref<Shader>& shader, const Ref<VertexArray>& vertexArray,
                          const glm::mat4& transform){

        shader->Bind();
//        shader->UploadUniformMat4("u_ViewProjection", m_SceneData->ViewProjectionMatrix);
//        shader->UploadUniformMat4("u_Transform", transform);
        shader->SetMat4("u_ViewProjection", m_SceneData->ViewProjectionMatrix);
        shader->SetMat4("u_Transform", transform);
        vertexArray->Bind();
        RenderCommand::DrawIndexed(vertexArray);
    }
    void Renderer::OnWindowResize(uint32_t width, uint32_t height) {
        RenderCommand::SetViewport(0, 0, width, height);
    }
}
